package com.ag.zlw.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ag.bean.TbGoodsstatus;
import com.ag.common.BaseAction;
import com.ag.common.IDUtil;
import com.ag.zlw.service.GoodsstatusService;


/**
 * 物品状态
 * 
 * @author 钟龙伟
 * 
 */

@Scope("prototype")
@Controller("GoodsstatusAction")
public class GoodsstatusAction extends BaseAction {
	private static final long serialVersionUID = -1478025497648926124L;
	@Resource(name = "GoodsstatusService")
	private GoodsstatusService service;
	private List<TbGoodsstatus> GoodsstatusList;
	private String message;
	private String gstatusId;
	private String gstatusName;

	TbGoodsstatus tbGoodsstatus = new TbGoodsstatus();

	public String find() {
		try {
			GoodsstatusList = service.findAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "main";
	}

	public String delete() {
		tbGoodsstatus.setGstatusId(gstatusId);
		try {
			service.delete(tbGoodsstatus);
			this.setMessage("delete success!");
		} catch (Exception e) {
			this.setMessage("delete fail!");
		}
		return "delete_success";
	}

	public String add() {
		tbGoodsstatus.setGstatusName(gstatusName);
		tbGoodsstatus.setA(IDUtil.PRESERVE);
		try {
			service.save(tbGoodsstatus);
			this.setMessage("save success!");
		} catch (Exception e) {
			this.setMessage("save fail!");
		}
		return "add_success";
	}

	public String modify() {
		tbGoodsstatus.setGstatusId(gstatusId);
		tbGoodsstatus.setGstatusName(gstatusName);
		tbGoodsstatus.setA(IDUtil.PRESERVE);
		try {
			service.modify(tbGoodsstatus);
			this.setMessage("modify success!");
		} catch (Exception e) {
			this.setMessage("modify fail!");
		}
		return "modify_success";
	}

	public List<TbGoodsstatus> getGoodsstatusList() {
		return GoodsstatusList;
	}

	public void setGoodsstatusList(List<TbGoodsstatus> goodsstatusList) {
		this.GoodsstatusList = goodsstatusList;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getGstatusId() {
		return gstatusId;
	}

	public void setGstatusId(String gstatusId) {
		this.gstatusId = gstatusId;
	}

	public String getGstatusName() {
		return gstatusName;
	}

	public void setGstatusName(String gstatusName) {
		this.gstatusName = gstatusName;
	}
	
	
}
